﻿namespace DimensionsHelper.LanguageService.Syntax;

public abstract class MetadataFieldReferenceSuffix : Declaration
{
    private MetadataField? _field;
    private MetadataFieldReference? _reference;

    internal MetadataFieldReferenceSuffix(SyntaxKinds kind, SyntaxToken declareKeywordToken, Identifier name,
        SyntaxNode? parent) :
        base(kind, declareKeywordToken, name, parent)
    {
    }

    public MetadataFieldReference? Reference => _reference;

    public MetadataField? Field => _field;


    public void Update(MetadataFieldReference reference)
    {
        SetChildNullableField(ref _reference, reference);
    }


    public void Update(MetadataField field)
    {
        SetChildNullableField(ref _field, field);
    }


    public override void AcceptVisitor<T>(SyntaxNodeVisitor<T> visitor)
    {
        base.AcceptVisitor(visitor);
        Accept(visitor, Reference, Field);
    }
}